/*
 * Copyright (c) 2012 Keerthi Ramachandran .
 */
package com.kee.example.domain;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * This class... todo (RK) javadoc
 *
 * @author <a href="mailto:Keerthi.Ramachandran@navis.com">Keerthi Ramachandran</a>, 8/29/12
 * @since 2.4. /2012-08-29
 */
@Entity
@Table(name = "JPAEX")
public class JPAClassEx {
    @Id @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;
    private String stringProp;
    private long longProp;
    @Embedded
    private Address address;
    @Embedded
    @AttributeOverrides({
            @AttributeOverride(name = "street", column = @Column(name = "home_street")),
            @AttributeOverride(name = "city", column = @Column(name = "home_city")),
            @AttributeOverride(name = "zipCode", column = @Column(name = "home_zipcode"))}
    )
    private Address homeAddress;

    public Address getHomeAddress() {
        return homeAddress;
    }

    public void setHomeAddress(Address inHomeAddress) {
        homeAddress = inHomeAddress;
    }

    public JPAClassEx() {
    }

    public long getId() {
        return id;
    }

    public Address getAddress() {
        return address;
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(this.stringProp).append(this.longProp).toHashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final JPAClassEx other = (JPAClassEx) obj;
        return new EqualsBuilder().append(this.stringProp, other.stringProp).append(this.longProp, other.longProp).isEquals();
    }

    public void setAddress(Address inAddress) {
        address = inAddress;
    }

    public void setId(long inId) {
        id = inId;
    }

    public String getStringProp() {
        return stringProp;
    }

    public void setStringProp(String inStringProp) {
        stringProp = inStringProp;
    }

    public long getLongProp() {
        return longProp;
    }

    public void setLongProp(long inLongProp) {
        longProp = inLongProp;
    }
}
